dojo.ready(function() {
    service.getAlunos()
    .addCallback(function(result) {
        var buffer = '';
        result.forEach(function(element) {
            var toCursoLink = function(target) {
                return '<a href="/curso.html#' + element.curso + '">' + target + '</a>'
            };
            var toAlunoLink = function(target) {
                return '<a href="/aluno.html#' + element._id + '">' + target + '</a>'
            };
            buffer += '<tr><td>'
                + toAlunoLink(element._id)
                + '</td><td>'
                + toAlunoLink(decodeURI(element.nome))
                + '</td><td>'
                + toCursoLink(element.curso)
                + '</td></tr>';
        });
        document.getElementById('alunos').innerHTML += buffer;
    })
    .addErrback(onErrback);

    document.title = 'Alunos - D.A.R. - Vinipsmaker labs';
});